- namespace = @group || @project&.namespace || @namespace
= webpack_bundle_tag 'tracker'
- if Gitlab.com?
  = webpack_bundle_tag 'analytics'
- tracking_context = Gitlab::Tracking::ContextFactory.for_frontend(user: current_user, namespace: namespace, project_id: @project&.id)
= javascript_tag do
  :plain
    window.snowplowOptions = #{Gitlab::Tracking.frontend_client_options(@group).to_json};
    gl = window.gl || {};
    gl.snowplowStandardContext = #{tracking_context.to_context.to_json.to_json};
    gl.snowplowPseudonymizedPageUrl = #{masked_page_url(group: namespace, project: @project).to_json};
    gl.maskedDefaultReferrerUrl = #{masked_referrer_url(request.referer).to_json};
    gl.ga4MeasurementId = 'G-ENFH3X7M5Y';
    gl.duoEvents = #{Gitlab::Tracking::EventEligibilityChecker.internal_duo_events.to_json};
    gl.onlySendDuoEvents = #{Gitlab::Tracking::EventEligibilityChecker.only_send_duo_events?};
